clear
use "Data1.dta"
save temp.dta, replace



*Table 2
clear
use temp.dta
keep if country==392

logit Y2 c.AGE, robust
outreg2 using a.doc, replace e(r2_p)

logit Y2 c.AGE male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)


logit Y2 i.over60, robust
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over60 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over65 , robust
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over65 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over70 , robust
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over70 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)


*Appendix A
clear
use temp.dta
keep if country==392

tab Y2 if AGE<30
tab Y2 if AGE>29 & AGE<40
tab Y2 if AGE>39 & AGE<50
tab Y2 if AGE>49 & AGE<60
tab Y2 if AGE>59 & AGE<70
tab Y2 if AGE>69

*Appendix B1, Table B1
clear
use temp.dta
keep if country==392
logit Y2 c.AGE male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, replace e(r2_p)

logit Y2 i.over60 male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over65 male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over70 male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 c.AGE##c.AGE male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 c.AGE##c.AGE##c.AGE male edu i.employed, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 AGE male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over60 male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over65 male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 i.over70 male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 c.AGE##c.AGE male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)

logit Y2 c.AGE##c.AGE##c.AGE male edu i.employed i.JP_REG, cluster(JP_REG)
outreg2 using a.doc, append e(r2_p)




*Appendix B1, Figure B1
clear
use temp.dta
keep if country==392

logit Y2 AGE male edu employed i.JP_REG, cluster(JP_REG)
margins, at(AGE=(20(1)85)) 
marginsplot, recast(line) noci xtitle(age) ytitle(Predicted probability) title(Model 7 (Age to the 1st power))
graph save 1, replace

logit Y2 c.AGE##c.AGE##c.AGE male edu employed i.JP_REG, cluster(JP_REG)
margins, at(AGE=(20(1)85)) 
marginsplot, recast(line) noci xtitle(age) ytitle(Predicted probability) title(Model 12 (Age cubed))
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom title(Predicted probability of inflation aversion, size(medium))


*Appendix B2
clear
use temp.dta
keep if country==392

ologit Y c.AGE male edu i.employed, robust
outreg2 using a.doc, replace e(r2_p)

ologit Y over60 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)

ologit Y over65 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)

ologit Y over70 male edu i.employed, robust
outreg2 using a.doc, append e(r2_p)

*Appendix B3
clear
use temp.dta
keep if country==392

mlogit Y c.AGE male edu i.employed, robust base(2)
outreg2 using a.doc, replace e(r2_p)

mlogit Y over60 male edu i.employed, robust base(2)
outreg2 using a.doc, append e(r2_p)

mlogit Y over65 male edu i.employed, robust base(2)
outreg2 using a.doc, append e(r2_p)

mlogit Y over70 male edu i.employed, robust base(2)
outreg2 using a.doc, append e(r2_p)


*Appendix B4 (Report OECD countries)
clear
use temp.dta
tab Y2 country, col
tab Y2 country if over65==1, col
tab Y2 country if over65==0, col
